<template>
    <div class="box">
        <span>用户名：</span>
        <br />
        <input type="text" v-model="username" />
        <br />
        <span>密码：</span>
        <br />
        <input type="text" v-model="password" />
        <br />
        <button @click="login">登录</button>
    </div>
</template>

<script>
export default {
    data() {
        return {
            username:'',
            password:''
        }
    },
    methods: {
        async login(){
            var url = "http://localhost:53000/user?username="+this.username+"&password="+this.password;
            var {data} = await this.$axios.get(url);
            if(data.length>0){
                this.$toast("登录成功")
                setTimeout(() => {
                    this.$router.push('/')
                }, 3000);
            }else{
                this.$toast("密码错误")
            }
        }
    },
};
</script>

<style>
</style>